<div class="row">

    <div class="col-md-12">      		
    	
    	<div class="widget stacked ">
    		<div class="widget-header">
                <i class="icon-list"></i>
                <h3><?php echo isset($title_for_layout)?$title_for_layout:$this->l('Patient profile'); ?></h3>
            </div> <!-- /.widget-header -->

            <div class="widget-content">
            	<div class="form-group">
                        <span class="col-md-8">
                            <a class="btn btn-primary" href="<?php echo base_url('Doctor/Patient/listing'); ?>"><?php echo $this->l('Return to patients list'); ?></a>
                            <a class="btn btn-primary" href="<?php echo base_url('Doctor/Patient/editPatient/?id='.$_GET['id']); ?>"><?php echo $this->l('Edit this patient'); ?></a>
                        </span>
                    </div>
                <div class="clearfix"></div>
            	<section id="tables">
                    <div class="page-header">
                        <h3><?php echo $title; ?></h3>
                    </div>
	            	<div class="col-md-4">
						<dl class="dl-horizontal">
						  <dt><?php echo $this->l('Username'); $this->l('Username'); ?></dt><dd><?php echo $user->username; ?></dd>
						  <dt><?php echo $this->l('Name and firstname'); ?></dt><dd><?php echo $user->firstname.' '.$user->lastname; ?></dd>
						  <dt><?php echo $this->l('Email'); ?></dt><dd><?php echo $user->email; ?></dd>
						  <dt><?php echo $this->l('Status'); ?></dt><dd><?php echo ($user->activated == '0') ? $this->l('Not confirmed') : ( ($user->activated == '2') ? $this->l('Activated') : $this->l('Confirmed') ); ?></dd>
						  <dt><?php echo $this->l('Last connexion'); ?></dt><dd><?php echo ($user->last_connexion == NULL) ? $this->l('Never') : /*format_date('d F Y', strtotime($user->last_connexion))*/$user->last_connexion; ?></dd>
						<?php 
							if (isset($patient) AND $patient != NULL){
						?>
							  <dt><?php echo $this->l('Patient birthday'); ?></dt><dd><?php echo /*format_date('d F Y', strtotime($patient->birthday))*/$patient->birthday; ?></dd>
							  <dt><?php echo $this->l('Phone'); ?></dt><dd><?php echo $patient->phone; ?></dd>
							  <dt><?php echo $this->l('Profession'); ?></dt><dd><?php echo $patient->profession; ?></dd>
							  <dt><?php echo $this->l('P.O.Box'); ?></dt><dd><?php echo $patient->pobox; ?></dd>
							  <dt><?php echo $this->l('Town'); ?></dt><dd><?php echo $patient->town; ?></dd>
							  <dt><?php echo $this->l('Address'); ?></dt><dd><?php echo $patient->address; ?></dd>
							  <dt><?php echo $this->l('Social security number'); ?></dt><dd><?php echo $patient->nb_secur_social; ?></dd>
							  <dt><?php echo  $this->l('CMU'); ?></dt><dd><?php echo ($patient->cmu == '0') ? $this->l('No') : $this->l('Yes'); ?></dd>
						<?php } ?>
						</dl>
					</div>
					<div class="col-md-8">
						<!-- Consultations list -->
						<table class="table table-bordered table-hover table-striped table-condensed">
							<caption class=""><?php echo $this->l('Consultations list for').' : '.$user->firstname.' '.$user->lastname; ?></caption>
	                        <thead>
	                          <tr>
	                            <th>#</th>
	                            <th><?php echo $this->l('Status'); ?></th>
	                            <th><?php echo $this->l('Type'); ?></th>
	                           
	                            <th><?php echo $this->l('Date'); ?></th>
	                            <th><?php echo $this->l('Actions'); ?></th>
	                          </tr>
	                        </thead>
	                        <tbody>
	                            <?php foreach ($consultations as $key => $value) { ?>
	                                <tr>
	                                    <td><?php echo $value->id_consultation; ?></td>
	                                    <td><?php echo $value->cons_status_label; ?></td>
	                                    <td><?php echo $value->cons_type_label; ?></td>
	                                    <td>
	                                        <?php $date = date_create_from_format('Y-m-d H:i:s', $value->date_add);
	                                        echo date_format($date, 'd F Y').' at ';
	                                        echo date_format($date, 'H:i A'); ?>
	                                    </td>
	                                    <td>
	                                    	<a class="btn btn-xs btn-success <?php if (!in_array($value->last_id_history, array('3','4','5')) OR $value->patient_is_connected == 0) { ?>disabled<?php }  ?>" href="<?php echo site_url('Doctor/Consultation/StartConsultation/'.$value->id_consultation); ?>">
	                                			<i class="icon icon-edit"></i>
	                                			<?php echo $this->l('Start consultation'); ?>
	                                		</a>
	                                    </td>
	                                </tr>
	                            <?php }  ?>                                                    
	                        </tbody>
	                    </table><!-- End of consultations list -->
	                    
	                    <!-- Prescriptions list -->
	                    <table class="table table-bordered table-hover table-striped table-condensed">
							<caption class="left"><?php echo $this->l('Prescriptions list for').' : '.$user->firstname.' '.$user->lastname; ?></caption>
	                        <thead>
	                          <tr>
	                            <th>#</th>
	                            <th><?php echo $this->l('Status'); ?></th>
	                            <th><?php echo $this->l('Content'); ?></th>
	                           
	                            <th><?php echo $this->l('Date'); ?></th>
	                            <th><?php echo $this->l('Actions'); ?></th>
	                          </tr>
	                        </thead>
	                        <tbody>
	                            <?php foreach ($prescriptions as $key => $value) { ?>
	                                <tr>
	                                    <td><?php echo $value->prescr_id; ?></td>
	                                    <td><?php echo $value->prescr_status == 1 ? $this->l('On') : $this->l('Off');; ?></td>
	                                    <td><?php echo $value->prescr_content; ?></td>
	                                    
	                                    <td>
	                                        <?php $date = date_create_from_format('Y-m-d H:i:s', $value->prescr_date);
	                                        echo date_format($date, 'd F Y').' at ';
	                                        echo date_format($date, 'H:i A'); ?>
	                                    </td>
	                                    <td>
	                                    	<a class="btn btn-xs btn-success" href="<?php echo site_url('Doctor/Prescription/Update/?id='.$value->prescr_id); ?>"><i class="icon icon-edit"></i></a>
                                        	<a class="btn btn-xs btn-primary" href="<?php echo site_url('Doctor/Prescription/send/?prescription='.$value->prescr_id.'&patient='.$value->id_patient); ?>"><i class="icon icon-envelope"></i></a>
                                        	<a class="btn btn-xs btn-danger" href="<?php echo site_url('Doctor/Prescription/stop/?id='.$value->prescr_id); ?>"><i class="icon icon-remove-sign"></i></a>
	                                    </td>
	                                </tr>
	                            <?php }  ?>                                                    
	                        </tbody>
	                    </table><!-- End of Prescriptions list -->
					</div>
				</section>	
    		</div> <!-- /widget-content -->
    			
    	</div> <!-- /widget -->
    	
    </div> <!-- /span12 -->

</div> <!-- /row -->